WRANGLERS

Which Countries are the Happiest?

Profiling

Photo by Alex Alvarez on Unsplash

Photo by Alex Alvarez on Unsplash

World Happiness Report

The World Happiness Report has proven to be an indispensable tool for policymakers
looking to better understand what makes people happy…
— Jeffrey Sachs


Ingest

df <- read_xls('./archetypes/happiness-report/happiness-report-2020.xls')
df

Dimensions

number of columns and rows

dim(df)
## [1] 1704   26

The output tells us that the data contains 1704 rows, and 26 columns.

Positive, Negative and Zero Values

Check for all the numerical columns

df1 <- df[,3:ncol(df)]

nRows <- dim(df1)[1]

calcStats <- function(x) {
  temp <- na.omit(df[, x])
  pos <- sum(temp > 0)
  is_zero <- sum(temp = 0)
  neg <-  sum(temp < 0)
  c("number of positives" = pos, "negatives" = neg, "zero" = is_zero)
}
  
result <- as.data.frame(Map(calcStats, colnames(df1)))
result

Histograms

for all numerical variables

df_long <- df %>%
  pivot_longer(
    `Life Ladder`:`Most people can be trusted, WVS round 2010-2014`,
    names_to = "measure",
    values_to = "value"
  )

v1 <- ggplot(df_long, aes(x=value)) +
  geom_histogram(fill = "#79B8E5") +
  facet_wrap(~ measure, scales="free")+
  theme(panel.grid = element_blank(), 
        strip.background = element_blank(),
        panel.background = element_blank()
 ) 

girafe(ggobj = v1, width_svg = 16, height_svg = 9, options =
  list(opts_sizing(rescale = TRUE, width = 1.0))
)

Just looking at the graph, we see that the “Life Ladder” varies from 0 to 8, with the majority of values between 4 and 6. “Log GDP per capita” varies from about 5 to 12. So the GDP per person would vary in this dataset from $150 to $160k.

References

citations for narrative and data sources:

  • Narrative and Data sources: The 7th World Happiness Report, GO
@misc{helliwell_2019_world,
  author = {  Helliwell,  John F. Helliwell and Layard, Richard  and Sachs, Jeffrey D. },
  title = {World Happiness Report 2019},
  url = {https://worldhappiness.report/ed/2019/},
  urldate = {2021-05-18},
  year = {2019},
  organization = {Worldhappiness.report}
}